﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;

/**
 *Copyright(C) 2019 by 殊未
 *All rights reserved.
 *FileName:     
 *Author:      丁冉
 *Version:      BVP3.0
 *UnityVersion:    2018.4.0
 *Date:         #DATE#
 *Description:   
 *History:
*/

public class SelectFile : MonoBehaviour
{
    public UIController uIController;
    public Button OpenBtn;
    public Text PathText;
    void Start()
    {
        OpenBtn.onClick.AddListener(OpenProject);
    }
    /// <summary>
    /// 打开项目
    /// </summary>
    public void OpenProject()
    {
        OpenFileDlg pth = new OpenFileDlg();
        pth.structSize = Marshal.SizeOf(pth);
        pth.filter = "Excel文件(*.xlsx;*.xls)\0*.xlsx;*.xls";

        pth.file = new string(new char[256]);
        pth.maxFile = pth.file.Length;
        pth.fileTitle = new string(new char[64]);
        pth.maxFileTitle = pth.fileTitle.Length;
        pth.initialDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); //默认路径
        pth.title = "选择文件";
        pth.defExt = "xls";
        pth.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;// 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008
        if (OpenFileDialog.GetOpenFileName(pth))
        {
            string filepath = pth.file; //选择的文件路径;
            uIController.SelectPath = filepath;
            PathText.text = filepath;
            uIController.SetData(filepath);
            uIController.m_selectInciseType.SetTabNameDropDown();
        }
    }
}
